home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / igncntl.aqm / igntrlc.asm
Assembly Source File  |  1985-04-26  |  6KB  |  177 lines

  1.          TITLE     CTRLLOCK - Ignore CTRL keystroke
  2. ;
  3. ;        After disk load, becomes resident
  4. ;        Attaches to interrupt
  5. ;
  6. ;        09h       Keystroke interrupt
  7. ;
  8. ;        Causes system to ignore CTRL key by decoding each
  9. ;        keystroke, and ignoring CTRL press
  10. ;
  11. ;        VERSION WITHOUT STACK AND DATA IN CSEG
  12. ;        DESIGNED TO BE RUN AS COM FILE
  13. ;
  14. CR       EQU       0Dh       ;Carriage return
  15. LF       EQU       0Ah       ;Line feed
  16. BELL     EQU       07h       ;Beep speaker
  17. ESC      EQU       01Bh      ;escape key
  18. TERM     EQU       '$'       ;String display terminator
  19. CHECK_SUM EQU      0FBFBh    ;To test if in memory already
  20. CTRL_SCAN EQU      01Dh      ;Scan code for CTRL key
  21. ;
  22. KEY_INT  EQU       09h       ;Keyboard interrupt
  23. KEY_ADDR EQU       09h*4     ;Keyboard interrupt address in memory
  24. ;
  25. ;
  26. CSEG     SEGMENT   PARA PUBLIC 'CODE'
  27.          ASSUME    CS:CSEG,DS:CSEG
  28. ;
  29. STARTNOW PROC      FAR
  30. ;
  31.          ORG       0100h     ;Required for COM programs
  32. ;
  33. START:   NOP
  34.          JMP       SETUP     ;First time, attach to interrupt and
  35. ;                            ;stay in memory
  36. ;
  37.          DW        CHECK_SUM ;For in memory test, do not insert anything
  38. ;                            ;before entry, checksum tested before
  39. ;
  40. KEY_ENTRY:
  41. ;
  42.          NOP
  43.          STI                 ;Reset interrupts
  44.          PUSH      DS        ;Save system
  45.          PUSH      ES
  46.          PUSH      AX
  47.          PUSH      BX
  48.          PUSH      CX
  49.          PUSH      DX
  50.          PUSH      SI
  51.          PUSH      DI
  52.          PUSH      BP
  53. ;
  54.          MOV       SI,CS               ;Get segment value
  55.          MOV       DS,SI               ;Into data segment
  56.          MOV       ES,SI               ;And extra
  57. ;
  58.          IN        AL,060h             ;Read keyboard input
  59. ;
  60.          TEST      AL,080h             ;See if key release
  61.          JNZ       KEY_RELEASED        ;Yes, ignore releases
  62. ;
  63.          CMP       AL,CTRL_SCAN        ;See if CTRL key depressed
  64.          JNZ       KEY_EXIT            ;No, go to normal handling
  65. ;
  66. ;                                      ;key we want, reset keyboard
  67. ;                                      ;port to acknowledge receipt
  68. ;                                      ;of keystroke info
  69. ;
  70.          IN        AL,061h             ;Read 8255 port
  71.          OR        AL,080h             ;Set acknowledge signal bit
  72.          OUT       061h,AL             ;Send acknowledge to port
  73.          AND       AL,07Fh             ;Reset acknowledge bit
  74.          OUT       061h,AL             ;Restore original 8255 port status
  75. ;
  76.          MOV       AL,020h             ;Send EOI to 8259 command reg
  77.          OUT       020h,AL
  78. ;
  79.          POP       BP
  80.          POP       DI                  ;Restore
  81.          POP       SI
  82.          POP       DX
  83.          POP       CX
  84.          POP       BX
  85.          POP       AX
  86.          POP       ES
  87.          POP       DS
  88.          IRET                          ;Return from interrupt
  89. ;
  90. KEY_RELEASED:
  91. KEY_EXIT:                              ;Handle keystroke normally,
  92.          POP       BP                  ;jump to regular keyboard handler
  93.          POP       DI
  94.          POP       SI                  ;Restore registers
  95.          POP       DX
  96.          POP       CX
  97.          POP       BX
  98.          POP       AX                  ;Jump to regular keyboard routine
  99.          POP       ES
  100.          POP       DS
  101. ;
  102.                    DB        0EAh      ;This produces far jump to below
  103. ;
  104. OLD_KEY_ADDR       DW        0         ;Store old keyboard int address
  105.                    DW        0
  106. ;
  107. ; -----------------------------------------------------------------
  108. ;
  109.          SUBTTL    SETUP routine for startup
  110.          PAGE
  111. ;
  112. SETUP_START:                           ;End of actual in-core program
  113. ;
  114. SETUP:
  115.          PUSH      CS
  116.          POP       DS                  ;Point here
  117. ;
  118.          MOV       AL,KEY_INT          ;Interrupt vector wanted
  119.          MOV       AH,035h             ;Get vector
  120.          INT       021h                ;To DOS
  121. ;                                      ;Returns ES:BX vector pointer
  122.          MOV       CX,BX
  123.          DEC       BX                  ;Back off to our checksum
  124.          DEC       BX
  125.          MOV       AX,ES:[BX]          ;Get the word in front of entry
  126.          CMP       AX,CHECK_SUM        ;See if already installed
  127.          JNE       KEEP_IN_MEMORY
  128. ;        JMP       ALREADY_INSTALLED   ;Yes
  129. ;
  130. ALREADY_INSTALLED:
  131.          MOV       DX,OFFSET ALREADY_INSTALLED_MESSAGE
  132.          MOV       AH,09               ;Print string
  133.          INT       021h
  134. ;
  135.          INT       020h                ;Just exit
  136. ;
  137. ; -----------------------------------------------------------------------
  138. KEEP_IN_MEMORY:
  139. ;
  140.          MOV       SI,OFFSET OLD_KEY_ADDR
  141.          MOV       CS:[SI],CX          ;Save in our program
  142.          MOV       CS:[SI+2],ES
  143. ;
  144.          MOV       DX,OFFSET KEY_ENTRY
  145.          MOV       AL,KEY_INT          ;Keyboard interrupt
  146.          MOV       AH,025h             ;Set interrupt vector to DS:DX
  147.          INT       021h
  148. ;
  149.          MOV       DX,OFFSET NOW_INSTALLED_MESSAGE
  150.          MOV       AH,09               ;Print string
  151.          INT       021h
  152. ;
  153.          MOV       DX,OFFSET SETUP_START ;Point to end of resident area
  154.          ADD       DX,0Fh              ;Leave some extra
  155.          INT       027h                ;Exit but remain resident
  156. ;
  157. ; -----------------------------------------------------------------------
  158. ;
  159. NOW_INSTALLED_MESSAGE:
  160.          DB        CR,LF
  161.          DB        'CTRLLOCK program now installed.'
  162.          DB        CR,LF
  163.          DB        TERM
  164. ;
  165. ALREADY_INSTALLED_MESSAGE:
  166.          DB        BELL
  167.          DB        CR,LF
  168.          DB        'CTRLLOCK program already installed.'
  169.          DB        CR,LF
  170.          DB        BELL
  171.          DB        TERM
  172. ;
  173. STARTNOW ENDP
  174. ;
  175. CSEG     ENDS
  176.          END       START
  177.